package com.woniu.springboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.woniu.springboot.entity.Student;
import com.woniu.springboot.service.Student2Service;

@Controller
@RequestMapping("/student")
public class Student2Controller {
	@Autowired
	Student2Service student2Service;
	
	/**
	 * 把从数据库中取出的数据存入model中，跳转到数据展示页面
	 * 页面使用模板引擎解析
	 * @param model
	 * @return
	 */
	@RequestMapping("/")
	public String getStudets(Model model) {
		List<Student> students = student2Service.getStudents();
		System.out.println(students);
		model.addAttribute("students", students);
		return "/studentlist";
	}
	
}
